<?php
namespace PLibrary;
/**
 *  配置文件操作类
 * @author dem
 *
 */
class TConfig {

	public static $instance = NULL;

	private $_configs = array();

	public static function instance() {
		if(self::$instance == NULL) {
			self::$instance = new self();
		}
		return self::$instance;
	}

	/**
	 * 设置全部配置文件
	 * @param type $configs
	 * @return \TConfig
	 */
	public function setAll($configs = array()) {
		$this->_configs = $configs;
		return $this;
	}
	

	/**
	 * 添加配置文件
	 * @param string $configKey
	 * @param unknown $config
	 */
	public function set($configKey = '', $config = array()) {
		$this->_configs[$configKey] = $config;
		return $this;
	}

	/**
	 * 获取配置文件
	 * @param string $configKey
	 */
	public function get($configKey = '') {
		if(empty($configKey)) {
			return $this->_configs;
		} else {
			return isset($this->_configs[$configKey]) ? $this->_configs[$configKey] : NULL;
		}
	}


	

}
